package org.projetjava.presentation;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class AjouterChoixDialogue extends JDialog{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private JComboBox comboResult;
	private JLabel resultLabel;
	private BoutonAjouter boutonAjouter;

	

	public AjouterChoixDialogue(JFrame parent, String title, boolean modal, BoutonAjouter boutonAjouter) {

		super(parent, title, modal);
		this.boutonAjouter = boutonAjouter;

		this.setSize(300, 150);
		this.setLocationRelativeTo(null);
		this.setResizable(false);
		this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
		this.initComponent();
		this.setVisible(true);
	}
	
	private void initComponent() {

		
		JPanel panListResultats = new JPanel();
		panListResultats.setBackground(Color.white);
		panListResultats.setPreferredSize(new Dimension(220, 60));
		panListResultats.setBorder(BorderFactory.createTitledBorder("Choisissez quelle item ajouter"));
		
		comboResult = new JComboBox();
		
		comboResult.addItem("Lieu");
		comboResult.addItem("Parcours");
		comboResult.addItem("News");


		resultLabel = new JLabel(" Choix : ");
		
		
		
		panListResultats.add(resultLabel);
		panListResultats.add(comboResult);



		JPanel content = new JPanel();
		content.setBackground(Color.white);
		
		content.add(panListResultats);
	

		JPanel control = new JPanel();
		JButton okBouton = new JButton("OK");
		
		

		okBouton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {	

				switch((String)comboResult.getSelectedItem())
				{
					case "Lieu" :
					{
						boutonAjouter.LancementCreationLieu();
						break;
					}
					case "News" :
					{
						boutonAjouter.LancementCreationNews();
						break;
					}
					
					case "Parcours" :
					{
						boutonAjouter.LancementCreationParcours();
						break;
					}
				}
				
				/*boutonRecherche.setSelection((String)comboResult.getSelectedItem());
				if(type == "Lieu")
				{
					boutonRecherche.chargementLieu();
				}else
				{
					boutonRecherche.chargementParcours();
				}*/
				
				//getConsultation().chargementLieu();
				setVisible(false);
			}

		});

		JButton cancelBouton = new JButton("Annuler");
		cancelBouton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setVisible(false);
				//boutonRecherche.getFenetrePrincipal().getRechercher().setEnabled(true);
			}
		});

		control.add(okBouton);
		control.add(cancelBouton);

		
		this.getContentPane().add(content, BorderLayout.CENTER);
		this.getContentPane().add(control, BorderLayout.SOUTH);
	}

}
